package com.ctbri.JWLetter.frame;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.WebApplicationContextUtils;


/**
 * 初始化操作
 * 
 * @author Hogan
 * 
 */
@Component
public class InitServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	private ApplicationContext app=null;
	
	@Override
	public void init() throws ServletException {
		super.init();
		app = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
		ESDataPooledConnection dataPooledConnection = app.getBean(ESDataPooledConnection.class);
		NeoDataPooledConnection neoDataPooledConnection = app.getBean(NeoDataPooledConnection.class);
		dataPooledConnection.init();
		neoDataPooledConnection.init();
	}

	@Override
	public void destroy() {
		app.getBean(ESDataPooledConnection.class).destroy();
	}
	
}

